<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
Dim ultype
ultype=trim(request.QueryString("ultype"))
%>
<!--#include file="../config.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<%checkadmin(1)%>
<html>
	<head>
		<title>FCKeditor - Uploaders Tests</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="style/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
function SendFile()
{
	var sUploaderUrl = cmbUploaderUrl.value ;
	txtUrl.value = '';

	var date = new Date();

	frmUpload.action = sUploaderUrl + '&time=' + date.getTime();
	if (document.getElementById('cmbType').value) {
		frmUpload.action = frmUpload.action + '&Type='+document.getElementById('cmbType').value;
	}
	if (document.getElementById('CurrentFolder').value) {
		frmUpload.action = frmUpload.action + '&CurrentFolder='+document.getElementById('CurrentFolder').value;
	}
	var fileName=document.getElementById("NewFile").value;
	var pos = fileName.lastIndexOf(".");
	var lastname = fileName.substring(pos,fileName.length);
	<%if ultype="flash" then%>
	if (lastname.toLowerCase()!=".swf" && lastname.toLowerCase()!=".flv")
	{
		 alert("您上传的文件类型为"+lastname+"，flash必须为.swf或.flv");
		 return false;
	}
	 <%else%>
	 if (lastname.toLowerCase()!=".jpg" && lastname.toLowerCase()!=".gif" && lastname.toLowerCase()!=".bmp" && lastname.toLowerCase()!=".png"  && lastname.toLowerCase()!=".jpeg")
	{
		 alert("您上传的文件类型为"+lastname+"，图片必须为.jpg,.gif,.bmp,.png");
		 return false;
	}
	 <%end if%>
	frmUpload.submit() ;

}
function isIE(){
	var br =navigator.userAgent.toLowerCase();
	return /msie/.test(br)&&!/opera/.test(br);
}
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
{
	switch ( errorNumber )
	{
		case 0 :	// No errors
			txtUrl.value = fileUrl ;
			fileUrl=fileUrl.replace("//","/");
			<%If request.QueryString("UserDir")="" Then %>
			if(isIE()){
			<%response.Write("parent."&request.QueryString("parentform")&"."&request.QueryString("inputname")&".value=fileUrl;")%>
			}else{
				parent.document.getElementById("<%=request.QueryString("inputname")%>").value=fileUrl;
			}
			<%else%>
			 parent.location.href="<%=RZ_ROOT%>admin/manage_template.asp?subdir=<%=request.QueryString("UserDir")%>";
			<%End if%>
			<%if ultype="flash" then%>
			alert( "成功上传Flash" ) ;
			<%else%>
			alert( "成功上传图片" ) ;
			<%end if%>
			
			break ;
		case 1 :	// Custom error
			alert( customMsg ) ;
			break ;
		case 10 :	// Custom warning
			txtUrl.value = fileUrl ;
			alert( customMsg ) ;
			break ;
		case 201 :
			txtUrl.value = fileUrl ;
			alert( '目录中存在同名文件，文件名已经重命名为： "' + fileName + '"' ) ;
			parent.location.href="<%=RZ_ROOT%>admin/manage_template.asp?subdir=<%=request.QueryString("UserDir")%>";
			break ;
		case 202 :
			alert( '不合法的文件' ) ;
			break ;
		case 203 :
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
			break ;
		default :
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
			break ;
	}
}
		</script>
	</head>
	<body style="margin-left:0px;margin-top:0px;">
	<input type="hidden" id="parentform" name="parentform" value="<%=request.QueryString("parentform")%>"/>
	<input type="hidden" id="inputname" name="inputname" value="<%=request.QueryString("inputname")%>"/>
	<input type="hidden" id="cmbUploaderUrl" value="editor/filemanager/connectors/asp/upload.asp?ultype=<%=ultype%>&Random=<%=request.QueryString("Random")%>&UserDir=<%=request.QueryString("UserDir")%>">
    <%if ultype="flash" then%>
	<input type="hidden"  id="cmbType" name="cmbType" value="Flash">
    <%else%>
    <input type="hidden"  id="cmbType" name="cmbType" value="Image">
    <%end if%>
	<input type="hidden" name="CurrentFolder" id="CurrentFolder" value="/">
	<form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post">
	请选择要上传的<%if ultype="flash" then%>Flash<%else%>图片<%end if%>：<input type="file" id="NewFile" name="NewFile">
	<input type="button" value="上传" onClick="SendFile();">
	</form>
	<INPUT id="txtUrl"  readonly type="hidden">
	<iframe name="UploadWindow" style="width:0px;height:0px;" src="javascript:void(0)"></iframe>
</body>
</html>